;; The factorial function is implemented here as efficiently as I
;; could while still making it use bignums.

(in-package :azala)

(defun ! (n)
  (declare (type (integer 0 #.most-positive-fixnum) n)
	   (optimize (speed 3) (space 0) (safety 0) (debug 1)))
  (if (< n 2)
      1
      (loop with accum of-type (integer 1) = 1
	    for x of-type (integer 2 #.most-positive-fixnum) from 2 to n
	    do (setf accum (* accum x))
	    finally (return accum))))